﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;
using Yule8xCommon.Typelib;
using Yule8xModel;
using Yule8xWechat.Applib;

namespace Yule8xWechat.Test
{
    public partial class DimondTransfer : System.Web.UI.Page
    {
        protected System.Data.DataTable dtList;
        protected WxUserInfoResult wxUser;
        protected int child_user_count, user_id;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                user_id = RequestUtil.GetInteger("user_id");
                if (user_id < 1)
                {
                    Response.Write("请输入user_id参数");
                    Response.End();
                }
                wxUser = UserModels.GetWxUserInfo(user_id);
                if (null == wxUser)
                {
                    Response.Write("未登录");
                    Response.End();
                }
                tb_user_id.Text = user_id.ToString();
                string msg;
                tb_game_id.Text = UserModels.GetGameID(user_id, null, "bozhong", out msg).ToString();
            }
        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {
            int user_id = StringUtil.ToInteger(tb_user_id.Text);
            int game_id = StringUtil.ToInteger(tb_game_id.Text);
            int number = StringUtil.ToInteger(tb_number.Text);
            int game_mact_id = RequestUtil.FormInteger("game_mact_id");
            int game_currency_number = number;
            switch (game_mact_id)
            {
                case 1:
                    game_currency_number = number * AppConf.GameCurrencyRate_Bozhong;
                    break;
                case 2:
                    game_currency_number = number * AppConf.GameCurrencyRate_Wanghu;
                    break;
            }
            string msg;
            bool result = GiveCardModels.ConvertDimondToGameCurrency(user_id, game_id, number, game_currency_number, game_mact_id, out msg);
            Response.Write(string.Format("result={0}, msg={1}", result, msg));
        }
    }
}